package com.wpml;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @Description
 * @Date 2021-08-27
 * @Author wangpei
 **/
public class ContextThreadLocal {

    private static final ThreadLocal<ServletContextBean> SERVLET_CONTEXT_THREAD_LOCAL = new ThreadLocal<>();

    public static void setServletContextThreadLocal(ServletContextBean context) {
        SERVLET_CONTEXT_THREAD_LOCAL.set(context);
    }

    public static ServletContext getServletContext() {
        return SERVLET_CONTEXT_THREAD_LOCAL.get().getServletContext();
    }

    public static HttpSession getSession() {
        return SERVLET_CONTEXT_THREAD_LOCAL.get().getSession();
    }

    public static HttpServletRequest getRequest() {
        return SERVLET_CONTEXT_THREAD_LOCAL.get().getRequest();
    }

    public static HttpServletResponse getResponse() {
        return SERVLET_CONTEXT_THREAD_LOCAL.get().getResponse();
    }

}
